CmdUtils.CreateCommand({
    name: "scala",
    homepage: "http://jweslley.googlecode.com/svn/trunk/ubiquity/",
    description: "Search's Scala API",
    help: "Simply type scala and the classname and it will do a google search for API documentation on that class",
    icon: "http://www.scala-lang.org/sites/default/files/favicon.gif",
    takes: {"class name": noun_arb_text},
    preview: function(pblock, directObject) {
        var searchTerm = directObject.text;
        var pTemplate = "Searches Scala for <b>${query}</b>";
        var pData = {query: searchTerm};
        pblock.innerHTML = CmdUtils.renderTemplate(pTemplate, pData);

        var url = "http://ajax.googleapis.com/ajax/services/search/web";
        var params = { v: "1.0", q: "site:http://www.scala-lang.org/docu/files/api/ "+searchTerm };

        jQuery.get( url, params, function(data) {
        var numToDisplay = 3;
        var results = data.responseData.results.splice( 0, numToDisplay );

         pblock.innerHTML = CmdUtils.renderTemplate( {file:"google-search.html"},
                          {results:results}
                        );
      }, "json");
    },
    execute: function( theClass){
        var URL = "http://www.google.com/search?hl=en&q=site:http://www.scala-lang.org/docu/files/api/%20"+theClass.text+"&btnG=Search&btnI=3564";
        Utils.openUrlInBrowser(URL);        
    }
});